<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试页面</title>
    <script src="./jquery-3.5.1.min.js"></script>
</head>

<body>
    <input type="tel" name="mobile" id="mobile" value="15311484568">
    <button id="btn02">获取验证码</button>
    <br>
    <span id="content02"></span>

</body>

</html>
<script>
    $(function(params) {
        let server = "http://localhost:8080"
        $('#btn02').click(function(e) {
            e.preventDefault();
            let token = sessionStorage.getItem('token') == undefined ? '' : sessionStorage.getItem('token');
            $.ajax({
                type: "GET",
                url: server + "/sendCode.action?t=" + new Date().getTime(),
                data: {
                    mobile: $('#mobile').val()
                },
                headers: {
                    'token': token,
                },
                dataType: "json",
                success: function(response) {
                    switch (response.code) {
                        case '200':
                            $('#content02').text(JSON.stringify(response));
                            sessionStorage.setItem('token', response.data);
                            break;
                        case '10007':
                            $('#content02').text(JSON.stringify(response));
                            break;
                        default:
                            break;
                    }

                    setTimeout(() => {
                        sessionStorage.removeItem('token');
                    }, 60000);
                }
            });
        });
    });
</script>